home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / echelon < prev    next >
Text File  |  1995-03-31  |  2KB  |  102 lines

  1. Subject: Matrix routines
  2.  
  3. BEGIN_RPL echelon.rpl
  4. %%HP: T(3)A(D)F(.);
  5. \<< \-> matr
  6.   \<<
  7.     IF 'matr' VTYPE
  8. 3 == matr SIZE SIZE
  9. 1 > AND
  10.     THEN 1 1 1 matr
  11. SIZE LIST\-> DROP \->
  12. det p q m n
  13.       \<<
  14.         WHILE 'p\<=m'
  15. \->NUM 'q\<=n' \->NUM AND
  16.         REPEAT 0 p
  17. \-> cmax k
  18.           \<< p m
  19.             FOR row
  20. matr row q 2 \->LIST
  21. GET ABS \-> x
  22.               \<<
  23. IF 'x>cmax'
  24. THEN x 'cmax' STO
  25. row 'k' STO
  26. END
  27.               \>>
  28.             NEXT
  29.             IF '
  30. cmax>.00001'
  31.             THEN 1
  32. n
  33.               FOR
  34. col matr p col 2
  35. \->LIST GET matr k
  36. col 2 \->LIST GET \->
  37. tp tk
  38. \<< matr k col 2
  39. \->LIST tp PUT 'matr'
  40. STO matr p col 2
  41. \->LIST tk PUT 'matr'
  42. STO
  43. \>>
  44.               NEXT
  45.               IF 'k
  46. >p'
  47.               THEN
  48. det NEG 'det' STO
  49.               END
  50. matr p q 2 \->LIST
  51. GET \-> l
  52.               \<< 1 n
  53. FOR col matr p col
  54. 2 \->LIST GET l / \->
  55. tl
  56.   \<< matr p col 2
  57. \->LIST tl PUT 'matr'
  58. STO
  59.   \>>
  60. NEXT l det * 'det'
  61. STO
  62.               \>> 1 m
  63.               FOR
  64. row matr row q 2
  65. \->LIST GET \-> l
  66. \<< 1 n
  67.   FOR col
  68.     IF 'row\=/p'
  69.     THEN matr row
  70. col 2 \->LIST GET
  71. matr p col 2 \->LIST
  72. GET l * - \-> tv
  73.       \<< matr row
  74. col 2 \->LIST tv PUT
  75. 'matr' STO
  76.       \>>
  77.     END
  78.   NEXT
  79. \>>
  80.               NEXT
  81. 'p' INCR DROP 'q'
  82. INCR DROP
  83.             ELSE 0
  84. 'det' STO 'q' INCR
  85. DROP
  86.             END
  87.           \>>
  88.         END
  89.       \>> matr
  90. "Reduced Echelon Matrix
  91.  "
  92. 1 DISP 1 FREEZE
  93.     ELSE matr
  94. "ECHEL Error:
  95. Not A Matrix"
  96. 1 DISP 1400 .065
  97. BEEP 1 FREEZE
  98.     END
  99.   \>>
  100. \>>
  101. END_RPL
  102.